package com.diyizu.youdianda.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.diyizu.youdianda.entity.YddTag;
import com.diyizu.youdianda.mapper.YddMapper;
import com.diyizu.youdianda.service.YddService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class YddServiceImpl implements YddService {

    @Autowired
    private YddMapper yddMapper;
    @Override
    public List<YddTag> getListTag() {
        LambdaQueryWrapper<YddTag> lqw = new LambdaQueryWrapper<>();
        lqw.orderByDesc(YddTag::getId);
        List<YddTag> yddTags = yddMapper.selectList(lqw);
        return yddTags;
    }

    @Override
    public boolean deleteTag(Integer id) {
        int i = yddMapper.deleteById(id);
        return true;
    }

    @Override
    public boolean addTag(YddTag yddTag) {
        yddMapper.insert(yddTag);
        return true;
    }

    @Override
    public boolean updateTag(YddTag yddTag) {
        yddMapper.updateById(yddTag);
        return true;
    }
}
